<?php
/**
 * Helper for extract information of user from
 */
class UserHelper extends AppHelper {
	/**
	 * Extract username from user data
	 * @param $user
	 * @return string
	 */
	function getUsername($user) {
		$userName = array();
		if (isset ($user['Profile']['last_name'])) {
			$userName[] = $user['Profile']['last_name'];
		} elseif (isset ($user['Profiles']['last_name'])) {
			$userName[] = $user['Profiles']['last_name'];
		}
		if (isset ($user['Profile']['first_name'])) {
			$userName[] = $user['Profile']['first_name'];
		} elseif (isset ($user['Profiles']['first_name'])) {
			$userName[] = $user['Profiles']['first_name'];
		}

		return implode(' ', $userName);
	}
}